<template>
    <el-row class="row-bg" justify="start">
        <a href="#/main/cms/lunbo/create">
            <el-button type="primary">
                创建
            </el-button>
        </a>
    </el-row>

    <div style="height:15px"></div>
    <el-table :data="lunboList" highlight-current-row style="width: 100%">
        <el-table-column property="id" label="ID" width="">
        </el-table-column>
        <el-table-column property="title" label="名称" width="">
        </el-table-column>
        
        <el-table-column property="desc" label="描述" width="">
        </el-table-column>
        <el-table-column property="name" label="位置" width="">
        </el-table-column>
        <el-table-column property="status" label="状态" width="">

            <template #default="scope">
                <span v-show="scope.row.status == 1" style="color:green">启用</span>
                <span v-show="(scope.row.status == 0)" style="color:red">禁用</span>
            </template>
        </el-table-column>

        <el-table-column property="" label="编辑" width="">

            <template #default="scope">
                <!-- <el-button link type="primary" size="small"
                @click.prevent="deleteNav(scope.row.id)" >
                    删除
                </el-button> -->
                <a class="el-button el-button--primary el-button--small" :href="'/main/cms/lunbo/edit/' + scope.row.id">编辑</a>
                <a class="el-button el-button--danger el-button--small" @click.prevent="deleteLunbo(scope.row.id)">删除</a>
                
            </template>
        </el-table-column>

    </el-table>

    <div class=" table-below ">

        <el-pagination @current-change="changePage" :page-size="per_page" layout="prev, pager, next" :total="total" />
    </div>
</template>

<script lang="ts" setup>
import axios from 'axios';
import { ref } from 'vue';
import { ElMessage } from 'element-plus';
import type { id } from 'element-plus/es/locale';
const search: any = ref<object>({
    name: ''
})
const lunboList: any = ref<object>()
const per_page: any = ref<number>(10);
const total: any = ref<number>();
const changePage: any = ref<number>(1);

const getLunboList = () => {

    const url = window.VITE_URL + '/admin.slide/index';

    // console.log(url,data)
    axios.get(url).then(res => {

        lunboList.value = res.data;

    });
    
}

getLunboList();

const deleteLunbo = ( row_id:number ) => {

    let url = window.VITE_URL + '/admin.slide/remove';

    url += '?id=' + row_id;

    axios.get(url).then( (res:any) => {

        // lunboList.value = res.data;

        getLunboList();

    });
    
}

</script>